package com.mingliqiye.minecraft.enchantment.conflict.fabric.mixin;

import com.mingliqiye.minecraft.enchantment.conflict.fabric.network.ConfigPayload;
import net.minecraft.network.Connection;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.CommonListenerCookie;
import net.minecraft.server.players.PlayerList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(PlayerList.class)
public abstract class PlayerListMixin {

    @Inject(method = "placeNewPlayer", at = @At("RETURN"))
    private void onPlayerConnect(
        Connection connection,
        ServerPlayer serverPlayer,
        CommonListenerCookie commonListenerCookie,
        CallbackInfo ci
    ) {
        ConfigPayload.sendToPlayer(serverPlayer);
    }
}
